//
//  search_iPad_Grid_ViewController.m
//  chilemat
//
//  Created by Cristian Gonzalez Figueroa on 13-03-14.
//  Copyright (c) 2014 Chilemat SpA. All rights reserved.
//

#import "search_iPad_Grid_ViewController.h"
#import "classGenericCell.h"
#import "MyCollectionViewCellSearch.h"

@interface search_iPad_Grid_ViewController ()

@end

@implementation search_iPad_Grid_ViewController

@synthesize CollectionViewSearch;
@synthesize dataArraySearch = _dataArraySearch;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _dataArraySearch.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
                 cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MyCollectionViewCellSearch *myCell = [collectionView
                                    dequeueReusableCellWithReuseIdentifier:@"MyCell"
                                    forIndexPath:indexPath];
    
    myCell.imgImageView.image = [UIImage imageNamed:@"img_llave.png"];
    
    classGenericCell *objCell = [_dataArraySearch objectAtIndex:indexPath.row];

    myCell.lblTrademark.text = objCell.strTrademark;

    myCell.lblTitleLabel.text = objCell.strTitleLabel;
    
    myCell.lblPrice.text = objCell.strPrice;
    
    return myCell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

/*
    classCategories *objCategories = [_dataArrayCategories objectAtIndex:indexPath.row];
    
    NSString *strIdDepartment = objCategories.strIdDepartment;
    
    NSLog(@"strIdDepartment=%@", strIdDepartment);
*/

}

- (void) retrieveDataSearch{
    
    [_dataArraySearch removeAllObjects];
    _dataArraySearch = [[NSMutableArray alloc] init];
    
    for (int i = 0; i<24; i++)
    {
        NSString *strTitleLabel = @"Llave desigual ploma";
        NSString *strSubtitleLabel = @"";
        NSString *strTrademark = @"DESIGUAL";
        NSString *strIdmark = [NSString stringWithFormat:@"%i", i];
        
        NSString *strSKU = @"DS1577";
        NSString *strIdProducto = [NSString stringWithFormat:@"%i" , i];
        NSString *strReviews = @"20";
        NSString *strPrice = @"$39.990 C/U";
        NSString *strOfferPrice = @"";
        NSString *strPriceDuplicated = @"";
        
        NSString *strDiscount = @"";
        NSString *strOfferTime = @"";
        NSString *strQty = @"";
        
        classGenericCell *objCell = [[classGenericCell alloc] initClassCell:strTitleLabel andSubtitleLabel:strSubtitleLabel andTrademark:strTrademark andIdMark:strIdmark andSKU:strSKU andStrIdProducto:strIdProducto andReviews:strReviews andstrPrice:strPrice andOfferPrice:strOfferPrice andstrPriceDuplicated:strPriceDuplicated andDiscount:strDiscount andOfferTime:strOfferTime andQty:strQty];
        
        [_dataArraySearch addObject:objCell];
    }
    
    [self.CollectionViewSearch reloadData];

}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self retrieveDataSearch];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
